import "package:flutter/material.dart";
import 'package:flutter_pink_app/style/text.dart';

// 个人页横栏组合
class ProfileRow extends StatelessWidget {
  final Map<String, String> categoryMap; // 类别栏
  final EdgeInsetsGeometry textVerticleGap; // 文字上下间隙
  final EdgeInsetsGeometry rowPadding; // 横栏内边距
  final EdgeInsetsGeometry rowMargin; // 横栏内边距
  final BoxDecoration rowDecoration;

  const ProfileRow(
      {Key key,
      this.rowDecoration,
      this.categoryMap = const {},
      this.textVerticleGap = const EdgeInsets.all(5),
      this.rowMargin,
      this.rowPadding = const EdgeInsets.symmetric(vertical: 10)})
      : super(key: key);

  Column _buildCategory(String cate, String amount) {
    return Column(
      children: <Widget>[
        Text(amount, style: subBlackStyle),
        Padding(
            padding: textVerticleGap, child: Text(cate, style: subGreyStyle))
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    final _items = <Widget>[];
    categoryMap.forEach((key, value) => _items
        .add(_buildCategory(key, value)));
    return Container(
      margin: rowMargin,
      padding: rowPadding,
      decoration: rowDecoration,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: _items,
      ),
    );
  }
}
